package com.guoxin.thread.concurrent.chapter6;

public class ThreadCloseGraceful {

    private static class Worker extends Thread {
        private volatile boolean status = true;

        @Override
        public void run() {
            while (status) {
                System.out.println("===>"+System.currentTimeMillis());
            }
            System.out.println("Therad is shutdown");
        }

        public void shutdown() {
            status = false;
        }
    }


    public static void main(String[] args) {
        Worker worker = new Worker();
        worker.start();

        try {
            Thread.sleep(10_000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        worker.shutdown();
    }
}
